package net.seabookchen.controller;

import java.util.logging.Logger;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.seabookchen.pojo.linkedin.LinkedInPerson;
import net.seabookchen.service.LinkedInResumeService;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;


@Controller
public class ResumeController {
	private static final Logger log = Logger.getLogger(ResumeController.class
			.getName());
	private LinkedInResumeService rService = null;
	
	public ResumeController() {
		if (rService == null) {
			rService = new LinkedInResumeService();
		}
	}
	
	@RequestMapping(value = "/resume/initprofile", method = RequestMethod.POST)
	public String initProfile() {
		rService.buildResumeFromLinkedIn();
		return "restful";
	}
	
	@RequestMapping(value = "/resume/profile", method = RequestMethod.GET)
	public String getProfile(HttpServletRequest request, HttpServletResponse resp, Model model) {
		LinkedInPerson profile = rService.getLinkedInProfile();
		model.addAttribute("resume", profile);
		return "showResume";
	}
}
